How to assign a richText string to an attribute

I have a string 'completeString' that I've created by concatenating the contents of several "Object Text"'s together by using the richTextWithOLE since some of these objects contain OLE tables. Once I've created this string I want to copy the concatenated string to an attribute that I've created. How do I make this assignment? I know for layout DXL 'displayRich completeString' would work but when I assign to an attribute I'm having problems viewing the content.
obj."attrName" = completeString;
lsand - Fri Nov 19 18:46:42 EST 2010

Re: How to assign a richText string to an attribute
Peter_Albert - Fri Nov 19 18:56:05 EST 2010

Try obj."attrName" = richText completeString

Regards,

Peter

Re: How to assign a richText string to an attribute
Mathias Mamsch - Fri Nov 19 19:05:37 EST 2010

And make sure when you concatenate the objects, use "richTextFragment" to cut off the RTF header. I experiences problems with concatenated OLEs without taking this into account. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: How to assign a richText string to an attribute
lsand - Fri Nov 19 21:16:57 EST 2010

Mathias Mamsch - Fri Nov 19 19:05:37 EST 2010
And make sure when you concatenate the objects, use "richTextFragment" to cut off the RTF header. I experiences problems with concatenated OLEs without taking this into account. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Thank you.

Re: How to assign a richText string to an attribute
SystemAdmin - Fri Mar 25 12:10:26 EDT 2011

Mathias Mamsch - Fri Nov 19 19:05:37 EST 2010
And make sure when you concatenate the objects, use "richTextFragment" to cut off the RTF header. I experiences problems with concatenated OLEs without taking this into account. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

I believe I'm following the steps cited in this post but I'm not getting the expected results.

I'm trying to insert some rich text in a DOORS text attribute. The content seems to be getting there but it does not render as expected.

Am I doing something wrong?

OBJECTIVE -- Insert rich text in an DOORS text attribute to be rendered in a specified fixed width font.

EXAMPLE OF DESIRED OUTPUT:

+-----+--------------------------+
| I   | want to                  |
+-----+--------------------------+
| be  | rendered as fixed-width  |
+-----+--------------------------+

 


CODE:

 

 

void showRawObjectText(Object o) {
    Module m = (Module current);
    string objText = richTextNoOle(o."Object Text");
    print "Raw Object Text is:\n" objText "\n"
}
 
void setObjectTextToFixedWidthFontString(Object o,
                                         string myFixedWidthLines[]) {
    string fixedWidthRtfPrefix = //-
        "{\\rtf1\\ansi\\deff0\\deflang1033\n" //-
        "{\\fonttbl{\\f555\\fmodern\\fprq1 Courier New;}}\n" //-
        "{\\viewkind4\\pard\\f555\n";
    string fixedWidthRtfContent = "";
    string fixedWidthRtfSuffix = //-
        "}\n" //-
        "}\n";
 
    int i;
    for (i = 0; i < sizeof(myFixedWidthLines); i++) {
        fixedWidthRtfContent = fixedWidthRtfContent //-
                               myFixedWidthLines[i] "\\par\n";
    }
 
    o."Object Text" = richText( fixedWidthRtfPrefix  //-
                                fixedWidthRtfContent //
                                fixedWidthRtfSuffix );
}
 
Object o = (Object current); 
 
string myAsciiTable[] = {
    "   +-----+--------------------------+",
    "   | I   | want to                  |",
    "   +-----+--------------------------+",
    "   | be  | rendered as fixed-width  |",
    "   +-----+--------------------------+"
}
 
setObjectTextToFixedWidthFontString(o, myAsciiTable);
 
showRawObjectText(o);



OUTCOME:
The myAsciiTable text makes it into the "Object Text" but is does not render in Courier New as instructed.

SECOND OPINION:
The RTF couldn't be too far off because if I paste the log output into an RTF file and open it in WordPad, it renders as expected.



 

 

{\rtf1\ansi\deff0\deflang1033
{\fonttbl{\f555\fmodern\fprq1 Courier New;}}
{\viewkind4\pard\f555
   +-----+--------------------------+\par
   | I   | want to                  |\par
   +-----+--------------------------+\par
   | be  | rendered as fixed-width  |\par
   +-----+--------------------------+\par
}
}



QUESTION:
1) Does the DXL code look proper?
2) Would a variation in RTF get it too work? Some RTF rendering clients need extra love to work as desired.

POSSIBILITY?:
I noticed a variation of the richTextFragment perm is:



 

 

string richTextFragment(string richString, string fontTable);



Would this help?



 

Re: How to assign a richText string to an attribute
Mathias Mamsch - Fri Mar 25 12:50:43 EDT 2011

SystemAdmin - Fri Mar 25 12:10:26 EDT 2011

I believe I'm following the steps cited in this post but I'm not getting the expected results.

I'm trying to insert some rich text in a DOORS text attribute. The content seems to be getting there but it does not render as expected.

Am I doing something wrong?

OBJECTIVE -- Insert rich text in an DOORS text attribute to be rendered in a specified fixed width font.

EXAMPLE OF DESIRED OUTPUT:

+-----+--------------------------+
| I   | want to                  |
+-----+--------------------------+
| be  | rendered as fixed-width  |
+-----+--------------------------+

 


CODE:

 

 

void showRawObjectText(Object o) {
    Module m = (Module current);
    string objText = richTextNoOle(o."Object Text");
    print "Raw Object Text is:\n" objText "\n"
}
 
void setObjectTextToFixedWidthFontString(Object o,
                                         string myFixedWidthLines[]) {
    string fixedWidthRtfPrefix = //-
        "{\\rtf1\\ansi\\deff0\\deflang1033\n" //-
        "{\\fonttbl{\\f555\\fmodern\\fprq1 Courier New;}}\n" //-
        "{\\viewkind4\\pard\\f555\n";
    string fixedWidthRtfContent = "";
    string fixedWidthRtfSuffix = //-
        "}\n" //-
        "}\n";
 
    int i;
    for (i = 0; i < sizeof(myFixedWidthLines); i++) {
        fixedWidthRtfContent = fixedWidthRtfContent //-
                               myFixedWidthLines[i] "\\par\n";
    }
 
    o."Object Text" = richText( fixedWidthRtfPrefix  //-
                                fixedWidthRtfContent //
                                fixedWidthRtfSuffix );
}
 
Object o = (Object current); 
 
string myAsciiTable[] = {
    "   +-----+--------------------------+",
    "   | I   | want to                  |",
    "   +-----+--------------------------+",
    "   | be  | rendered as fixed-width  |",
    "   +-----+--------------------------+"
}
 
setObjectTextToFixedWidthFontString(o, myAsciiTable);
 
showRawObjectText(o);



OUTCOME:
The myAsciiTable text makes it into the "Object Text" but is does not render in Courier New as instructed.

SECOND OPINION:
The RTF couldn't be too far off because if I paste the log output into an RTF file and open it in WordPad, it renders as expected.



 

 

{\rtf1\ansi\deff0\deflang1033
{\fonttbl{\f555\fmodern\fprq1 Courier New;}}
{\viewkind4\pard\f555
   +-----+--------------------------+\par
   | I   | want to                  |\par
   +-----+--------------------------+\par
   | be  | rendered as fixed-width  |\par
   +-----+--------------------------+\par
}
}



QUESTION:
1) Does the DXL code look proper?
2) Would a variation in RTF get it too work? Some RTF rendering clients need extra love to work as desired.

POSSIBILITY?:
I noticed a variation of the richTextFragment perm is:



 

 

string richTextFragment(string richString, string fontTable);



Would this help?



 

Experimenting with your code, the following did the trick:
 

// ...
    string fixedWidthRtfPrefix = //-
        "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\ftech Courier New;}}"
// ...

 


Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: How to assign a richText string to an attribute
SystemAdmin - Fri Mar 25 17:45:58 EDT 2011

Mathias Mamsch - Fri Mar 25 12:50:43 EDT 2011

Experimenting with your code, the following did the trick:
 

// ...
    string fixedWidthRtfPrefix = //-
        "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\ftech Courier New;}}"
// ...

 


Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Thanks Mathias. The good news is is works. The troublesome part is why.

The literature says:

A font is defined by its name, a font number, and a font family, as
shown in the following example. Semicolons are used as delimites
between fonts.
 
    {\fonttbl\f0\froman Tms Rmn;}...
            A      B    C      D
 
        A   Control word
        B   Font number
        C   Font family
        D   Font name
 
The font numbers represent the full font definitions in the group, and
vary with each document. The font families are listed below:
 
        Control Word    Font Family
        ------------------------------------------
        \fnil           Unknown or default fonts (default)
        \froman         Roman, proportionally spaced serif fonts
                        (TmsRmn, Palatino, etc.)
        \fswiss         Swiss, proportionally spaced sans serif fonts
                        (Swiss, etc.)
        \fmodern        Fixed-pitch serif and sans serif fonts
                        (Courier, Elite, Pica, etc.)
        \fscript        Script fonts (Cursive, etc.)
        \fdecor         Decorative fonts (Old English, Zapf Chancery,
                        etc.)
        \ftech          Technical, symbol, and mathematical fonts
                        (Symbol, etc)
 
If an RTF file uses a default font, the default font number is
specified with the \deff n control word, which must precede the font
table group. The RTF writer supplies the default font number used in
the creation of the document as the numeric argument. The RTF reader
then translates this number through the font table into the most
similar font available on the reader's system.


Courier fonts are generally associated the "fmodern" family.

My theorem is is by saying "use Courier New" AND it is (inappropriately) in the "ftech" family, perhaps DOORS is letting a special override slide through. I'm curious about why it takes something hokey like this to temporarily override a default font.

It is not the first non-obvious kludge I've seen trying to do something perfectly normal with DOORS and probably won't be the last.

Re: How to assign a richText string to an attribute
Mathias Mamsch - Fri Mar 25 19:51:51 EDT 2011

SystemAdmin - Fri Mar 25 17:45:58 EDT 2011

Thanks Mathias. The good news is is works. The troublesome part is why.

The literature says:

A font is defined by its name, a font number, and a font family, as
shown in the following example. Semicolons are used as delimites
between fonts.
 
    {\fonttbl\f0\froman Tms Rmn;}...
            A      B    C      D
 
        A   Control word
        B   Font number
        C   Font family
        D   Font name
 
The font numbers represent the full font definitions in the group, and
vary with each document. The font families are listed below:
 
        Control Word    Font Family
        ------------------------------------------
        \fnil           Unknown or default fonts (default)
        \froman         Roman, proportionally spaced serif fonts
                        (TmsRmn, Palatino, etc.)
        \fswiss         Swiss, proportionally spaced sans serif fonts
                        (Swiss, etc.)
        \fmodern        Fixed-pitch serif and sans serif fonts
                        (Courier, Elite, Pica, etc.)
        \fscript        Script fonts (Cursive, etc.)
        \fdecor         Decorative fonts (Old English, Zapf Chancery,
                        etc.)
        \ftech          Technical, symbol, and mathematical fonts
                        (Symbol, etc)
 
If an RTF file uses a default font, the default font number is
specified with the \deff n control word, which must precede the font
table group. The RTF writer supplies the default font number used in
the creation of the document as the numeric argument. The RTF reader
then translates this number through the font table into the most
similar font available on the reader's system.


Courier fonts are generally associated the "fmodern" family.

My theorem is is by saying "use Courier New" AND it is (inappropriately) in the "ftech" family, perhaps DOORS is letting a special override slide through. I'm curious about why it takes something hokey like this to temporarily override a default font.

It is not the first non-obvious kludge I've seen trying to do something perfectly normal with DOORS and probably won't be the last.

Yeah, I wondered about this too... I just thought well DOORS supports symbol fonts, why not try tech and see if anything happens, and curiously it came out in Courier. No idea, just luck ... Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS